package com.cqc.jdk8.Jlang.thread;


public class HThread extends Thread {

    private final String lock = "a";


    @Override
    public void run() {
        //threadName:Thread-0，holdsLock：false
        System.out.println("start,threadName:" + this.getName() + "，holdsLock：" + Thread.holdsLock(lock));
        synchronized (lock) {
            //threadName:Thread-0，holdsLock：true
            System.out.println("threadName:" + this.getName() + "，holdsLock：" + Thread.holdsLock(lock));
        }
        //end,threadName:Thread-0，holdsLock：false
        System.out.println("end,threadName:" + this.getName() + "，holdsLock：" + Thread.holdsLock(lock));
    }
}